package cn.edu.sgu.www.pms.pager;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Data
@ApiModel
public class Pager<T> implements Serializable {
    private static final long serialVersionUID = 18L;

    /**
     * 页数
     */
    @ApiModelProperty(value = "页数", required = true)
    private Integer page;

    /**
     * 每页的记录数
     */
    @ApiModelProperty(value = "每页的记录数", required = true)
    private Integer rows;

    /**
     * 根据Pager创建Page对象
     * @param pager Pager
     * @return Page
     */
    public static <T> Page<T> ofPage(Pager<T> pager) {
        return new Page<T>(pager.getPage(), pager.getRows());
    }

}